<?php
	include("dboper.php");

	if(!@$_POST['akses'] == true) {
	   die('Akses langsung tidak diperbolehkan!');
	}
	
	$h_asisten = getAllAsisten();
	 echo '<h4>Daftar Asisten</h4>';
	
?>
<br>

<table id="listAsisten">
<tr>
	<td>Nama</td><td>NIM</td><td>Foto</td>
</tr>
<?php

	while ($d_asisten = mysql_fetch_array($h_asisten)) {
		echo '<tr><td>
				'.$d_asisten['nama_asisten'].'</td><td>'.$d_asisten['nim_asisten'].'</td><td><a rel="prettyPhoto" href="http://www.amikom.ac.id/public/fotomhs/20'.substr($d_asisten['nim_asisten'],0,2).'/'.$d_asisten['nim_asisten'].'.jpg" title="&nbsp&nbsp'.$d_asisten['Nama'].' ('.$d_asisten['NIM'].')" ><img src="http://www.amikom.ac.id/public/fotomhs/20'.substr($d_asisten['nim_asisten'],0,2).'/'.$d_asisten['nim_asisten'].'.jpg" title="&nbsp&nbsp'.$d_asisten['Nama'].' ('.$d_asisten['NIM'].')" width="25" /></a></td>
				
				</tr>';	
	}

?>
</table>    
<link rel="stylesheet" href="pretty.css" type="text/css" media="screen" charset="utf-8" />
<script src="pretty.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
    
    $("a[rel^='prettyPhoto']").prettyPhoto({social_tools:false});

	$("#addAsisten").click(function(e){
		 $("#fb_content").load('addasisten.php', {akses:true});
	});
	
	$('#listAsisten a').on('click', function(event) {
		$("#loading").show();
		//alert($(this).attr('alt'));
		if($(this).attr('id') == 'hapusAsisten'){
			var id = $(this).attr('alt');	
			$.prompt("Apakah anda yakin untuk menghapus data dengan ID "+id+"?", {
				title: "Informasi",
				buttons: { "Ya": true, "Tidak" : false },
				submit:function(e,v,m,f){
					if(v == true){
						$.ajax({
						type: "POST", 
						url: 'deleteasisten.php',   
						data : { idAsisten : id, akses : true} ,
						success: function(a){
							alert('Data sukses dihapus, silahkan refresh.');
							$("#loading").hide();
							return true;
						},
						error: function(){
							alert("Data gagal dihapus");	
							$("#loading").hide();
							return false;
						}
						}); 
						$("#loading").hide();
					} else {
						$("#loading").hide();
					}
				}
			});			
		} else if ($(this).attr('id') == 'ubahAsisten'){
            var id = $(this).attr('alt');	
			$("#fb_content").load('editasisten.php', {akses:true, idAsisten:id});
            $("#loading").hide();
		} else {
        $("#loading").hide();
        }
        
     return false;
	});
</script>

